import axios from 'axios'

import React, { Component } from 'react'

export default class Axios extends Component {
    constructor(props) {
      super(props)
    
      this.state = {
         list:[]
      }
    }
    

    componentDidMount() {
        this.getaxios()
    }

    getaxios = () => {
        const api = "https://www.easy-mock.com/mock/5c4961cb28a69b32a72d2c1b/testmock/list"
        axios.get(api).then((response) => {
            console.log(response.data.list)
            this.setState({
                list:response.data.list
            })
        }).catch((error) => {
            console.log(error);
        });
       
    }

    render() {
        return (
            <ul>
                {this.state.list.map((val,key)=>{
                    return <li key={key}>{val.title}</li>
                })}
            </ul>
        )
    }
}

